package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.AreaListBean;
import com.fy.fyzf.bean.CommonSearchBean;
import com.fy.fyzf.bean.DemandListBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.DemanddetailBean;
import com.fy.fyzf.bean.GetDemandDetailBean;
import com.fy.fyzf.bean.IsInfoBean;
import com.fy.fyzf.bean.IssueDemandBean;
import com.fy.fyzf.bean.MyRecommendBean;
import com.fy.fyzf.bean.ReleaseBean;
import com.fy.fyzf.view.DemandCallBack;

import java.util.List;

public class DemandPresenter extends BasePresenter<DemandCallBack> {
    public DemandPresenter(DemandCallBack view) {
        super(view);
    }

    public void getDemandList(CommonSearchBean commonSearchBean){
        addSubscription(mApiService.getDemandList(commonSearchBean), new SubscriberCallBack<BaseData<DemandListBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<DemandListBean> response) {
                mView.getDemandListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void issueDemand(IssueDemandBean issueDemandBean) {
        addSubscription(mApiService.issueDemand(issueDemandBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.issueDemandSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void editDemand(IssueDemandBean issueDemandBean) {
        addSubscription(mApiService.editDemand(issueDemandBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.issueDemandSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getAreaData(int flag,Integer id) {
        addSubscription(mApiService.listClassification(flag, id), new SubscriberCallBack<BaseData<List<AreaListBean>>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<List<AreaListBean>> response) {
                mView.getAreaListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getDamendDetail(GetDemandDetailBean commonSearchBean){
        addSubscription(mApiService.demandDetail(commonSearchBean), new SubscriberCallBack<BaseData<DemanddetailBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<DemanddetailBean> response) {
                mView.getDamendDetailSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getMyDemandList(CommonSearchBean commonSearchBean) {
        addSubscription(mApiService.myDemand(commonSearchBean), new SubscriberCallBack<BaseData<DemandListBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<DemandListBean> response) {
                mView.getMyDemandListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void deleteDemand(ReleaseBean releaseBean,int i) {
        addSubscription(mApiService.delRelease(releaseBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.deleteDemandSuccess(response,i);
            }

            @Override
            protected void onError() {

            }
        });
    }


    public void listMyRecommend(GetDemandDetailBean getDemandDetailBean){
        addSubscription(mApiService.listMyRecommend(getDemandDetailBean), new SubscriberCallBack<BaseData<MyRecommendBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<MyRecommendBean> response) {
                mView.getMyRecommendSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void isInfo(){
        addSubscription(mApiService.isInfo(0), new SubscriberCallBack<BaseData<IsInfoBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<IsInfoBean> response) {
                mView.isInfoSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }
}
